<? include ('inc/config.php'); ?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title><?=$_CONF->get('CONFIG>ADMIN>TITLE.nodeValue');?></title>
<style>@import 'css/common.css';</style>
<script type="text/javascript" src="js/common.js"></script>
<script type="text/javascript" src="js/MenuTree.js"></script>
</head>
<body id="menu">
<div id="menuContent">
	
	<div class="menuHeader">
		<h3>Benvenuto <strong><?=$_SESSION['FF']['logName']?></strong></h3>
		
		<div class="menuRefreshButton">
			<a href="#" onClick="window.location = 'menu.php';"><img src="i/ico_refresh_small.gif"></a>
		</div>
	</div>
	
	<div id="menuRightBar">&nbsp;</div>
	
	<br>
	<ul id="MenuTree">
	<?
	$_MENU = $_CONF->get("CONFIG>ADMIN>ADMINMENU.childNodes");
	$_TABLES = $_CONF->get("CONFIG>TABLES.node");
	$menuRow = 0;
	foreach($_MENU as $key => $content) {
		
		if($_CONF->get("MENUHEADER.defcon", $content) <= $_SESSION['FF']['logType']) {
			// Ho i permessi per vedere questo menu'
			
			switch ($_CONF->get("MENUHEADER.type", $content)) {
				case "*MAIL*": 
					echo '<li><a href="mailto:'.$_CONF->get("MENUHEADER.nodeValue", $content).'">'.$_CONF->get("MENUHEADER.name", $content)."</a></li>";
					break;
					
				case "*DATABASE*": 
					// Stampo il menu per questo utente
					echo '<li><a href="javascript:FF.visual.openMenuRow(\'MenuRow_'.$menuRow.'\')" title="'.$_MSG['open_menu_row'].'">'.$_CONF->get("MENUHEADER.name", $content)."</a>";
					echo '<ul>';
					$tables = $_DB->getTablesName();
					foreach($tables as $table) {
						$getTable = $_CONF->get("TABLES>TABLE.name=$table.node", $_TABLES);
						$accountTable = $_CONF->get("ACCOUNT>TABLES>TABLE.name=$table.node", $_SESSION['FF']['logArray']);
						
						if(($_SESSION['FF']['logType'] == 0 && $accountTable) || ($_SESSION['FF']['logType'] != 0 && $getTable['attributes']['VISIBLE'] != 'false')) {
							// Stampo la voce
							$title = $getTable['attributes']['TITLE'];
							echo '<li><a target="content" href="content.php?table='.$table.'" target="content" title="'.$_CONF->get("CONFIG>TABLES>TABLE.name=$table>DESCRIPTION.nodeValue").'">'.(($title)?$title:$table).'</a>';
							$plugins = $_CONF->get("TABLE.name=$table>PLUGINS.childNodes", $getTable);
							if(count($plugins) > 0 && $plugins !== false) {
								echo '<ul>';
								foreach($plugins as $plugin) {
									echo '<li><a href="pluginManager.php?action=runPlugin&table='.$table.'&name='.$plugin['attributes']['NAME'].'&file='.$plugin['attributes']['VALUE'].'" target="content">'.$plugin['attributes']['NAME'].'</a></li>';
								}
								echo '</ul>';
							}
							echo ' <!--a href="" class="txtBtn green">+</a-->';
							echo '</li>';
						}
					}
					echo '</ul>';
					echo '</li>';
					break;
				
				case "*MENU*": 
					
					$dir = $_CONF->get("CONFIG>ADMIN>ADMINPATH.nodeValue").(($_CONF->get("MENUHEADER.dir", $content))?$_CONF->get("MENUHEADER.dir", $content).'/':'');
					echo '<li><a href="javascript:FF.visual.openMenuRow(\'MenuRow_'.$menuRow.'\')">'.$_CONF->get("MENUHEADER.name", $content).'</a>';
						echo '<ul>';
						$subMenu = $_CONF->get("MENUHEADER.childNodes", $content);
						foreach($subMenu as $subHr => $subValue) {
							echo '<li><a target="content" href="'.$dir.$_CONF->get("CONTENT.page", $subValue).'">'.$_CONF->get("CONTENT.name", $subValue).'</a></li>';
						}
						echo '</ul>';
					echo '</li>';
					break;
					
			}
		}
		$menuRow++;
	}
	
	?>
	</ul>
	<script language="javascript">
	var menu = FF.MenuTree.init("MenuTree");
	FF.visual.setWindowControllers('menuRightBar');
	</script>
	
</div>
</body>
</html>
